//
//  RoadTableViewCell.m
//  NineGroupProject
//
//  Created by dllo on 15/12/23.
//  Copyright © 2015年 蓝鸥科技. All rights reserved.
//

#import "RoadTableViewCell.h"
#import "UIImageView+WebCache.h"
@implementation RoadTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubViews];
    }
    return self;
}

- (void)createSubViews
{
    
#pragma mark - 图像图片
    self.image_urlImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"loading.jpg"]];
    self.image_urlImageView.frame = CGRectMake(5 * WID, 5 * WID, WIDTH - 5 * WID * 2, 160 * HEI);
    [self.contentView addSubview:self.image_urlImageView];
    self.image_urlImageView.userInteractionEnabled = YES;

    
#pragma mark - 标题
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.image_urlImageView.frame.origin.x + 5 * WID, self.image_urlImageView.frame.size.height - 50 * HEI, WIDTH - 10 * WID * 2, 30 * HEI)];
    [self.contentView addSubview:self.nameLabel];
    self.nameLabel.textColor = [UIColor whiteColor];
    self.nameLabel.font = [UIFont boldSystemFontOfSize:18];
    self.nameLabel.numberOfLines = 0;

    
#pragma mark - 小标题
    self.dayLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.image_urlImageView.frame.origin.x + 10 * WID, self.image_urlImageView.frame.size.height - 20 * HEI, WIDTH - 10 * 2 * WID, 20 * HEI)];
    [self.contentView addSubview:self.dayLabel];
    self.dayLabel.textColor = [UIColor whiteColor];
    self.dayLabel.font = [UIFont systemFontOfSize:15];

    
#pragma mark - 描述
    self.descriptionLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.image_urlImageView.frame.origin.x, self.image_urlImageView.frame.size.height + 5 * HEI, WIDTH - 10 * 2 * WID, 50 * HEI)];
    [self.contentView addSubview:self.descriptionLabel];
    self.descriptionLabel.textColor = [UIColor blackColor];

    self.descriptionLabel.numberOfLines = 0;
    self.descriptionLabel.font = [UIFont systemFontOfSize:13];
    
    
    
}


-(void)setRoadModel:(RoadModel *)roadModel{

    self.nameLabel.text = roadModel.name;
    self.descriptionLabel.text = roadModel.myDescription;
    [self.descriptionLabel sizeToFit];
    
    
    NSString *count = [NSString stringWithFormat:@"%@天 / %@个旅行地", roadModel.plan_days_count, roadModel.plan_nodes_count];
    self.dayLabel.text = count;
    
    
    [self.image_urlImageView sd_setImageWithURL:[NSURL URLWithString:roadModel.image_url] placeholderImage:[UIImage imageNamed:@"loading.jpg"]];
    
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
